/**
 * @type {Date}
 *
 * @properties={typeid:35,uuid:"3DED6F07-AA93-4940-96DD-5D769D21F293",variableType:93}
 */
var fFechaHasta = new Date();

/**
 * @type {Date}
 *
 * @properties={typeid:35,uuid:"4CE04C27-D25E-4F9C-A96C-455C5F792559",variableType:93}
 */
var fFechaDesde = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"FFF16EE6-0896-4C43-8310-B755F871899A",variableType:4}
 */
var fProducto = null;

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"EEFABA77-B433-4881-816C-C71B7357F378"}
 * @AllowToRunInFind
 */
function buscar(event) {
	controller.find()
	
	producto_id = fProducto
	
	var $rango = utils.dateFormat(fFechaDesde,'dd-MM-yyyy')+'...'+utils.dateFormat(fFechaHasta,'dd-MM-yyyy')
	fecha = '#' + $rango + '|dd-MM-yyyy'
	
	if (controller.search() == 0)
		globals.DIALOGS.showWarningDialog('Aviso','No se encontraron resultados','OK')
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"4302F307-D68A-4FE1-BF2E-CC601EE08BF9"}
 */
function productoNull(event) {
	fProducto = null
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"9E660870-18D9-4D8E-92C8-B2A503F25810"}
 */
function fechasNull(event) {
	fFechaDesde = null
	fFechaHasta = null
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"7AFF6F53-E3B0-4CC4-AB95-FF72D8BFB023"}
 */
function onShow(firstShow, event) {
	databaseManager.revertEditedRecords()
	databaseManager.setAutoSave(true)
	
	controller.loadRecords(null)
}
